package com.kedi.archivescenter.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kedi.archivescenter.service.PcBusinessServicesService;
import com.kedi.archivescenter.write.dao.mapper.PcBusinessServicesMapper;

/**
 * 
 *
 * @ClassName OldhomeService
 * @author: 陈辽逊
 * @date: 2019/7/13 12:13
 */
@Service
public class PcBusinessServicesServiceImpl implements PcBusinessServicesService {

	@Autowired
	public PcBusinessServicesMapper mapper;

	final static Logger logger = LoggerFactory.getLogger(PcBusinessServicesServiceImpl.class);

	/**
	 * 返回一个数据对象
	 * 
	 * @param businessid
	 * @return updatelikenum
	 */
	@Override
	public int updatelikenum(int businessid) {
		try {
			int  a = mapper.updatelikenum(businessid);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("修改失败");
			return 0;
		}
	}

	/**
	 * 返回一个数据对象
	 * 
	 * @param businessid
	 * @return updatecollectnum
	 */
	@Override
	public int updatecollectnum(int businessid) {
		try {
			int  a = mapper.updatecollectnum(businessid);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("修改失败");
			return 0;
		}
	}

	/**
	 * 返回一个数据对象
	 * 
	 * @param name
	 * @return classname
	 */
	@Override
	public List<Map<String, Object>> classname(String name) {
		try {
			List<Map<String, Object>>  a = mapper.classname(name);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("查询失败");
			return null;
		}
	}

	/**
	 * 返回一个数据对象
	 * 
	 * @param map
	 * @return business
	 */
	@Override
	public int business(Map map) {
		try {
			int  a = mapper.business(map);
			return a;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("修改失败");
			return 0;
		}
	}

	/**
	 * 插入失败事务回滚
	 * 
	 * @param map
	 * @return merchant
	 */
	@Override
	@Transactional(rollbackFor = Exception.class, transactionManager = "secondaryTransactionManager")
	public boolean merchant(Map map) {
		int a = mapper.state(map);
		int b = mapper.merchant(map);
		if (a == 1 && b == 1) {
			return true;
		} else {
			return false;
		}

	}
}
